﻿using System;
using System.Text.RegularExpressions;

namespace ParseURL
{
    class ParseURL
    {
        static void Main(string[] args)
        {
            string url = "http://www.devbg.org/forum/index.php";
            Regex pattern = new Regex(@"(?<protocol>\w+)://(?<server>www\.[\w\d]*\.\w{2,4})/(?<resource>([\w\d]*/?)+\.\w{2,4})");
            Match match = pattern.Match(url);
            Group protocol = match.Groups["protocol"];
            Console.WriteLine("[Protocol] = {0}", protocol);
            Group server = match.Groups["server"];
            Console.WriteLine("[Server] = {0}", server);
            Group resource = match.Groups["resource"];
            Console.WriteLine("[Resource] = {0}", resource);
        }
    }
}